<?php


namespace app\system\controller;

class Feedback extends AdminBase
{
	public function get_data_list()
	{
		$options = $this->request->get();
		$options["limit"] = $this->page_size;
		$options["page"] = $this->page_no;
		$result = \app\system\service\FeedbackService::get_data_list($options);
		$this->response($result["code"], "获取成功", $result["data"], ["count", $result["count"]], ["pages", $result["pages"]]);
	}
	public function get_data_info($id)
	{
		$options = ["id" => $id];
		$result = \app\system\service\FeedbackService::get_data_info($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "获取成功", $result["data"]);
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function edit_data()
	{
		$options = $this->request->post();
		$validate = \think\Validate::make(["id" => "require", "appid" => "require", "content" => "require"], ["id.require" => "id 不能为空", "appid.require" => "appid 不能为空", "title.require" => "title 不能为空", "content.require" => "content 不能为空"]);
		if (!$validate->check($options)) {
			$this->response(\app\system\model\Code::fail, $validate->getError());
		}
		$result = \app\system\service\FeedbackService::edit_data($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "编辑成功");
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function del_data()
	{
		$options = $this->request->post();
		$result = \app\system\service\FeedbackService::del_data($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "删除成功");
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function get_classify_list()
	{
		$options = $this->request->get();
		$options["limit"] = $this->page_size;
		$options["page"] = $this->page_no;
		$result = \app\system\service\FeedbackService::get_classify_list($options);
		$this->response($result["code"], "获取成功", $result["data"], ["count", $result["count"]], ["pages", $result["pages"]]);
	}
	public function get_classify_info($id)
	{
		$options = ["id" => $id];
		$result = \app\system\service\FeedbackService::get_classify_info($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "获取成功", $result["data"]);
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function add_classify()
	{
		$options = $this->request->post();
		$validate = \think\Validate::make(["appid" => "require", "name" => "require", "sort" => "require"], ["appid.require" => "appid 不能为空", "name.require" => "名称 不能为空", "sort.require" => "排序 不能为空"]);
		if (!$validate->check($options)) {
			$this->response(\app\system\model\Code::fail, $validate->getError());
		}
		$result = \app\system\service\FeedbackService::add_classify($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "添加成功");
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function edit_classify()
	{
		$options = $this->request->post();
		$validate = \think\Validate::make(["id" => "require", "appid" => "require", "name" => "require", "sort" => "require"], ["id.require" => "id 不能为空", "appid.require" => "appid 不能为空", "name.require" => "名称 不能为空", "sort.require" => "排序 不能为空"]);
		if (!$validate->check($options)) {
			$this->response(\app\system\model\Code::fail, $validate->getError());
		}
		$result = \app\system\service\FeedbackService::edit_classify($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "编辑成功");
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
	public function del_classify()
	{
		$options = $this->request->post();
		$result = \app\system\service\FeedbackService::del_classify($options);
		if ($result["code"] == 1) {
			$this->response($result["code"], "删除成功");
		} else {
			$this->response($result["code"], $result["msg"]);
		}
	}
}